package com.ay.weixin.fdc.boss.user.db;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import lizar.db.ibatis.Dao;

import com.ay.weixin.fdc.boss.user.domain.UserWeiXinInfo;

public class WeiXinInfoDao extends Dao {
	
	public void insert(UserWeiXinInfo weixin) throws SQLException{
		this.sqlMapper.insert("weixin_info.insert",weixin);
	}
	
	public void update_user_id(UserWeiXinInfo weixin) throws SQLException{
		
		this.sqlMapper.update("weixin_info.update_user_id",weixin);
	}
	
	public void delete_old(String new_openid,long user_id) throws SQLException{
		Map<String,Object> args=new HashMap<String,Object>();
		args.put("new_openid",new_openid);
		args.put("user_id",user_id);
		
		this.sqlMapper.update("weixin_info.delete_old",args);
	}
	
	public void update(UserWeiXinInfo weixin) throws SQLException{
		this.sqlMapper.update("weixin_info.update",weixin);
	}
	
	public UserWeiXinInfo get(String id) throws SQLException{
		return (UserWeiXinInfo)this.sqlMapper.queryForObject("weixin_info.get",id);
	}
	
	public UserWeiXinInfo getByUserId(long user_id) throws SQLException{
		return (UserWeiXinInfo)this.sqlMapper.queryForObject("weixin_info.getByUserId",user_id);
	}
}
